<?php

namespace app\common\model\user;

use think\Model;


class UserCard extends Model
{
    

    // 表名
    protected $name = 'user_year_card';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
    ];
    

    
    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    /**
     * @return Model|\think\model\relation\BelongsTo
     * 关联年卡
     */
    public function card()
    {
        return $this->belongsTo('YearCard', 'card_id','id',[], 'LEFT')->setEagerlyType(1);
    }




}
